window.onload = function(){

    var sound1 = new Howl({
        src: ['./sounds/sound1.wav']
    });
    var sound = document.getElementById("sound");
    var board = document.getElementById("board");
    if(sound){
        board.onclick = function(e){
            var e = e||window.event;
            var x = e.clientX / window.screen.width;
            var y = e.clientY / window.screen.height;
            if(x > 0.1 && x < 0.9 && y > 0.4 && y < 0.8){  
                // sound.play();
                sound1.play();
                showText(e.clientX,e.clientY);
            }
        }
    }

    function showText(x,y) {
        var text = document.createElement("span");
        text.innerText = "静心+1";
        text.style.zIndex = 999;
        text.style.position = 'absolute';
        text.style.left = x + 'px';
        text.style.top = y + 'px';
        text.style.color = '#fff';
        text.style.transition = "opacity 2s,top 2s";
        setTimeout(() => {
            text.style.top = y - 150 + 'px';
            text.style.opacity = 0;
        }, 500);
        setTimeout(() => {
            text.remove();
        }, 2500);
        board.appendChild(text);
    }
}



